load("//bzl:cpp_library.bzl", "cpp_library")

package(default_visibility = ["//visibility:public"])

cpp_library(
    name = "atomic_utils",
    hdrs = ["AtomicUtils.h"],
    deps = [
        "//folly/lang:assume",
    ],
)

cpp_library(
    name = "hazptr_utils",
    hdrs = [
        "HazptrUtils.h",
    ],
    deps = [
        ":sleeper",
        "//folly:portability",
        "@glog",
    ],
)

cpp_library(
    name = "rcu-detail",
    hdrs = [
        "ThreadCachedLists.h",
        "ThreadCachedReaders.h",
        "ThreadCachedTag.h",
    ],
    deps = [
        "//folly:function",
        "//folly:synchronized",
        "//folly:thread_local",
        "//folly/synchronization:asymmetric_thread_fence",
        "//folly/synchronization:relaxed_atomic",
        "@glog",
    ],
)

cpp_library(
    name = "sleeper",
    srcs = ["Sleeper.cpp"],
    hdrs = ["Sleeper.h"],
    deps = [
        "//folly:portability",
        "//folly/portability:asm",
    ],
)

cpp_library(
    name = "spin",
    hdrs = ["Spin.h"],
    deps = [
        "//folly/portability:asm",
        "//folly/synchronization:wait_options",
    ],
)

cpp_library(
    name = "inline_function_ref",
    hdrs = [
        "InlineFunctionRef.h",
        "//folly:function",
        "//folly:traits",
        "//folly:utility",
        "//folly/functional:invoke",
    ],
)

cpp_library(
    name = "hardware",
    #srcs = [
    #    # Use source-specific flags so that these flags aren't applied to this
    #    # rules headers when they're compiled as a module, as they don't contain
    #    # any code that requires RTM and they'd conflict when imported by
    #    # dependents that don't also set it.
    #    (
    #        "Hardware.cpp",
    #        ["-mrtm"],
    #    ),
    #],
    srcs = ["Hardware.cpp"],
    hdrs = ["Hardware.h"],
    deps = [
        "//folly:cpp_attributes",
        "//folly:portability",
        "//folly/lang:assume",
        "//folly/lang:exception",
        "@boost.preprocessor",
    ],
)
